/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.ref;

/**
 * <p>Project: app2022 - RecordDemo
 * <p>Powered by webrx On 2022-02-09 17:20:43
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class RecordDemo {
    public static void main(String[] args) {
        var r = new Student(12, "李四");
        System.out.println(r.id());
        System.out.println(r.name());
        System.out.println(r);

        var book = new Book(100, "《java项目入门》", 60d);
        System.out.println(book);
        System.out.println(book.name);
        System.out.println(book.name());

        book.show();

        var b2 = new Book(20);
        System.out.println(b2);

    }

    record Book(int id, String name, double price) {
        static String address = "郑州";

        public Book(int id) {
            this(id, "《web前端》", 50d);
        }

        public Book() {
            this(1, "", 20d);
        }

        public void show() {
            System.out.println(this.name);
            {
                System.out.println(2 * 2);
            }
        }
    }
}
